my $string = 'How to Format
- put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**`
- indent code by 4 spaces
- backtick escapes `like _so_`
- quote by placing > at start of line
- to make links
<http://foo.com>
[foo](http://foo.com)';
print $string;

if ($string =~ /escape/) {
  # Count the number of newlines before the match.
  # Add 1 to make the first line 1 instead of 0.
  my $line = 1 + substr($string, 0, $-[0]) =~ tr/\n//;

  print "found at line $line\n";
}